﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace HMI.View
{
    /// <summary>
    /// MianContain.xaml 的交互逻辑
    /// </summary>
    public partial class MianContain : System.Windows.Controls.UserControl
    {
        public MianContain()
        {
            InitializeComponent();
            contx.selectTab = new Action<int>((int index) =>
            {
                contx.SelectIndex = index;
                menu.SelectMenu(index);
            });
            menu.ClickItem = new Action<ProjectModel>((ProjectModel model) =>
            {
                menu.SelectMenu(model.Index);
                contx.SelectIndex = model.Index;

            });
            menu.HideAction = new Action<bool>((bool bl) => {
                if (bl)
                {
                    gd.ColumnDefinitions[0].Width = new GridLength(50);
                }
                else
                {
                    gd.ColumnDefinitions[0].Width = new GridLength(280);
                }
            });

        }
        public void FillControl(int tabIndex, System.Windows.Controls.UserControl userControl)
        {
            TabItem tabItem = null;
            switch (tabIndex)
            {
                case 1:
                    tabItem = contx.tab1;
                    break;
                case 2:
                    tabItem = contx.tab2;
                    break;
                case 3:
                    tabItem = contx.tab3;
                    break;
                case 4:
                    tabItem = contx.tab4;
                    break;
                case 5:
                    tabItem = contx.tab5;
                    break;
                case 6:
                    tabItem = contx.tab6;
                    break;
            }

            tabItem.Content = userControl;
            userControl.Margin = new Thickness(5);
        }
    }
}
